<template>
	<view class="">
		<u-navbar :is-back="true" :border-bottom="false" title="工种信息" height="46" title-color="#333" :title-bold="true"
		 :title-size="36">
			<view class="navbar-right" slot="right" @click="Store">
				确认
			</view>
		</u-navbar>
		<view class="textarea_box">
			<u-form :model="form" :rules="rules" ref="uForm" :errorType="errorType">
				<u-form-item label-width="150" :label-position="labelPosition" label="工种名称" prop="gz" class="name-box" :label-style="labelStyle">
					<u-input placeholder="请输入工种名称" v-model="form.gz.name" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"
					 @click="show=true" :clearable="false"></u-input>
					<u-picker v-model="show" mode="selector" :range="typegz" range-key="name" @confirm="confirmgz"></u-picker>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="班组长" prop="bzz" class="name-box" :label-style="labelStyle">
					<u-radio-group v-model="form.bzzsf" v-if="form.bzz">
						<u-radio @change="radioChange" v-for="(item, index) in bzzData" :key="index" :name="item.name">
							{{item.name}}
						</u-radio>
					</u-radio-group>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="健康状况" prop="jkzk" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请输入健康状况" v-model="form.jkzk" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"></u-input>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="技能等级" prop="jndj" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请输入技能等级" v-model="form.jndj" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"
					 @click="jndjshow=true" :clearable="false"></u-input>
					<u-picker v-model="jndjshow" mode="selector" :range="jndjData" range-key="name" @confirm="confirmjndj"></u-picker>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="证书编号" prop="jndjzsbh" class="name-box"
				 :label-style="labelStyle">
					<u-input placeholder="请输入证书编号" v-model="form.jndjzsbh" type="text" :custom-style="{fontSize: '30rpx',}" :height="30"></u-input>
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="工作内容" prop="gznr" class="name-box"
				 :label-style="labelStyle">
					<u-input v-model="form.gznr" type="textarea" placeholder="您的在校经历的简要描述" height="300" :custom-style="{fontSize: '30rpx'}"
					 :clearable="false" />
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="工作范围" prop="gzfw" class="name-box"
				 :label-style="labelStyle">
					<u-input v-model="form.gzfw" type="textarea" placeholder="您的在校经历的简要描述" height="300" :custom-style="{fontSize: '30rpx'}"
					 :clearable="false" />
				</u-form-item>
				<u-form-item label-width="150" :label-position="labelPosition" label="服务标准" prop="fwbz" class="name-box"
				 :label-style="labelStyle">
					<u-input v-model="form.fwbz" type="textarea" placeholder="您的在校经历的简要描述" height="300" :custom-style="{fontSize: '30rpx'}"
					 :clearable="false" />
				</u-form-item>
			</u-form>
			<u-toast ref="uToast"/>
		</view>

	</view>

</template>

<script>
	export default {
		data() {
			return {
				id: "",
				show: false,
				jndjshow: false,
				bzzsf: "",
				form: {
					gz: '',
					bzz: '',
					jkzk: '',
					jndj: '',
					jndjzsbh: '',
					gznr: '',
					gzfw: '',
					fwbz: '',
				},
				jndjData: [{
						name: "初级"
					},
					{
						name: "中级"
					},
					{
						name: "高级"
					}
				],
				bzzData: [{
						name: "是"
					},
					{
						name: "否"
					}
				],
				typegz: [],
				rules: {

				},
				errorType: ['message'],
				labelPosition: "top",
				labelStyle: {
					height: "36rpx",
					fontSize: "24rpx",
					color: "#666666",
				},
			}
		},
		async onLoad(options) {
			this.id = options.id
			if (options.index) {
				this.index = options.index
			}
			await this.lCodedata()
			await this.resumemy(options.id)
		},
		methods: {
			radioChange(e) {
				if (e == "是") {
					this.form.bzz = "【班组长】"
				} else {
					this.form.bzz = " "
				}
			},
			async resumemy(id) {
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myquery',
					para: {
						"id": id,
					}
				}
				const res = await this.$u.api.resumedata(params)
				this.form.gz = this.typegz.filter(item => item.id == res.Data.gz)[0];
				this.form.bzz = res.Data.bzz
				if (this.form.bzz=="【班组长】") {
					this.form.bzzsf = "是"
				} else {
					this.form.bzzsf = "否"
				}
				this.form.jkzk = res.Data.jkzk
				this.form.jndj = res.Data.jndj
				this.form.jndjzsbh = res.Data.jndjzsbh
				this.form.gznr = res.Data.gznr
				this.form.gzfw = res.Data.gzfw
				this.form.fwbz = res.Data.fwbz
			},
			async lCodedata() {
				let params = {
					cmd: 'lCode_list_proc',
					para: {
						"pageindex": 1,
						"pagesize": 1000
					}
				}
				const res = await this.$u.api.lCodedata(params)
				this.typegz = res.Data.Data.filter(item => item.ctype == 1);
			},
			confirmgz(e) {
				this.form.gz = this.typegz[e[0]]
			},
			confirmjndj(e) {
				this.form.jndj = this.jndjData[e].name
			},
			async Store() {
				let $t=this
				let params = {
					ak: this.$store.state.token,
					cmd: 'lPeople_myupdate',
					para: {
						"gz": this.form.gz.id,
						"bzz": this.form.bzz,
						"jkzk": this.form.jkzk,
						"jndj": this.form.jndjzsbh,
						"gznr": this.form.gznr,
						"gzfw": this.form.gzfw,
						"fwbz": this.form.fwbz,
						"id": this.id
					}
				}
				const res = await this.$u.api.resumexgdata(params)
				if(res.ResponseID==0){
					this.$refs.uToast.show({
						title: res.Message,
						icon:false,
						duration:800,
						callback(){
						uni.$emit('refreshData');
						uni.navigateBack({
							delta: 1
						})
						}
					})
					
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.name-box {
		padding: 30rpx;
	}

	.navbar-right {
		margin-right: 30rpx;
		font-size: 30rpx;
	}
</style>
